using System;
using System.Collections.Generic;
using System.Text;
using CompareSpringProxy.Model;
using Spring.Context;
using Spring.Context.Support;

namespace CompareSpringProxy.Client
{
    class Program
    {
        static void Main(string[] args)
        {
            // start the spring context.
            IApplicationContext ctx = ContextRegistry.GetContext();

            // warn up the spring as well as the Web Service server
            IHelloWorld warmUp1 = (IHelloWorld)ctx.GetObject("WarmUpHelloWorld1");
            warmUp1.SayHello("warmUp1");
            IHelloWorld warmUp2 = (IHelloWorld)ctx.GetObject("WarmUpHelloWorld2");
            warmUp2.SayHello("warmUp2");


            DateTime startTime;
            TimeSpan timeSpan;
            string result;

            // Gether the performance

            startTime = DateTime.Now;
            IHelloWorld codeGen1 = (IHelloWorld)ctx.GetObject("WSCodeGenHelloWorld1");
            result = codeGen1.SayHello("codeGen1");
            timeSpan = DateTime.Now - startTime;
            Console.WriteLine("{0} took {1}", result, timeSpan);

            startTime = DateTime.Now;
            IHelloWorld proxy1 = (IHelloWorld)ctx.GetObject("SpringProxyHelloWorld1");
            result = proxy1.SayHello("Proxy1");
            timeSpan = DateTime.Now - startTime;
            Console.WriteLine("{0} took {1}", result, timeSpan);

            startTime = DateTime.Now;
            IHelloWorld proxy2 = (IHelloWorld)ctx.GetObject("SpringProxyHelloWorld2");
            result = proxy2.SayHello("Proxy2");
            timeSpan = DateTime.Now - startTime;
            Console.WriteLine("{0} took {1}", result, timeSpan);

            startTime = DateTime.Now;
            IHelloWorld codeGen2 = (IHelloWorld)ctx.GetObject("WSCodeGenHelloWorld2");
            result = codeGen2.SayHello("codeGen2");
            timeSpan = DateTime.Now - startTime;
            Console.WriteLine("{0} took {1}", result, timeSpan);

            Console.WriteLine("Press enter to continue...");
            Console.ReadLine();
        }
    }
}
